package com.cskaoyan.demo1;

import com.cskaoyan.demo1.bean.Student;
import com.cskaoyan.demo1.util.JacksonUtil;
import com.fasterxml.jackson.core.JsonProcessingException;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class JacksonDateApplication {
    public static void main(String[] args) throws ParseException, JsonProcessingException {
        Date birthday = new SimpleDateFormat("yyyy-MM-dd").parse("2003-08-25");
        Student student = Student.builder()
                .name("张三")
                .age(18)
                .address("北京")
                .birthday(birthday)
                .lastLoginTime(new Date())
                .build();
        String json = JacksonUtil.toJson(student);
        System.out.println(json);
        String josnStr2 = "{\"name\":\"张三\",\"age\":18,\"address\":\"北京\",\"birthday\":\"2003-08-25\",\"lastLoginTime\":\"2025-09-02 11:15:01\"}";
        Student parse = JacksonUtil.parse(josnStr2, Student.class);
        System.out.println(parse);
    }
}
